/**
 * 包含功能：
 * push, pop, peak(返回栈顶元素但对栈不做任何修改), isEmpty, size
 */
export class Stack {
    constructor() {
        this.items = []
    }

    push(element) {
        this.items.push(element)
    }

    pop() {
        return this.items.pop()
    }

    peak() {
        if (this.items.length === 0) {
            return null
        }
        return this.items[this.items.length - 1]
    }

    isEmpty() {
        return this.items.length === 0
    }

    size() {
        return this.items.length
    }
}